<?php

namespace App\Http\Controllers\Car;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\CarService;
use Illuminate\Http\Request;
//精选服务
class CarServiceController extends Controller
{
    use ResponseData;
    //
    public function index(CarService $service){
        $data = $service->get();
        return $this->success($data);
    }
    public function store(CarService $ser,Request $request){
        $data = $ser->create($request->all());
        return $this->success($data);
    }
    public function edit(CarService $service,Request $request){
        $data = $service->find($request->id);
        return $this->success($data);
    }
    public function update(CarService $service,Request $request){
        $model = $service->find($request->id);
        $data = array(
            'name'=>$request->name,
            'price'=>$request->price,
            'introduction'=>$request->introduction,
            'status'=>$request->input('status',1)
        );
        $model->update($data);
        return $this->success('更新成功');
    }

    public function destory(CarService $service,Request $request){
        $model = $service->find($request->id);
        $model->delete();
        return $this->success('删除成功');
    }
}
